package patrol.mobile.com.mobilepatrol.adapter;

import android.content.Context;

import com.dl7.recycler.adapter.BaseQuickAdapter;
import com.dl7.recycler.adapter.BaseViewHolder;

import java.util.ArrayList;
import java.util.List;

import patrol.mobile.com.mobilepatrol.R;
import patrol.mobile.com.mobilepatrol.bean.TrafficAllBean;

/**
 * Created by K on 2018/9/13.
 * des:
 */
public class TrafficAllAdapter extends BaseQuickAdapter<TrafficAllBean> {
    private List<TrafficAllBean> mData = new ArrayList<>();

    public TrafficAllAdapter(Context context) {
        super(context);
    }

    public void setData(List<TrafficAllBean> list) {
        mData = list;
        notifyDataSetChanged();
    }

    @Override
    public int getItemCount() {
        return mData == null ? 0 : mData.size() + 1;
    }

    @Override
    protected int attachLayoutRes() {
        return R.layout.item_traffic_all;
    }

    @Override
    protected void convert(BaseViewHolder holder, TrafficAllBean item) {
        if (holder.getAdapterPosition() == 0) {
            holder.setText(R.id.itemFormText01, "日期");
            holder.setText(R.id.itemFormText02, "出口（辆）");
            holder.setText(R.id.itemFormText03, "入口（辆）");
            holder.setText(R.id.itemFormText04, "合计（辆）");
            holder.setTextColor(R.id.itemFormText01, mContext.getResources().getColor(R.color.excelBlue));
            holder.setTextColor(R.id.itemFormText02, mContext.getResources().getColor(R.color.excelBlue));
            holder.setTextColor(R.id.itemFormText03, mContext.getResources().getColor(R.color.excelBlue));
            holder.setTextColor(R.id.itemFormText04, mContext.getResources().getColor(R.color.excelBlue));
        } else {
            holder.setText(R.id.itemFormText01, mData.get(holder.getLayoutPosition() - 1).getUpDate());
            holder.setText(R.id.itemFormText02, mData.get(holder.getLayoutPosition() - 1).getExitus());
            holder.setText(R.id.itemFormText03, mData.get(holder.getLayoutPosition() - 1).getEntrance());
            holder.setText(R.id.itemFormText04, mData.get(holder.getLayoutPosition() - 1).getTotal());
        }
    }
}
